/**
 * 配置
 * */
package org.zmhhxl.sample3.oauth2.a.configure.clientRepository;


import org.springframework.context.annotation.Bean;
import org.springframework.security.oauth2.server.authorization.client.InMemoryRegisteredClientRepository;
import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository;

/**
 *
 * 启用自定义registered client配置
 *
 *
 * @Configuration used to map OAuth2AuthorizationServerProperties to registered clients and settings.
 * {@link org.springframework.boot.autoconfigure.security.oauth2.server.servlet.OAuth2AuthorizationServerConfiguration},
 * 2024-4-7
 * */
//@Configuration
public class ClientStoreConfig {

   /**
    * 配置属性映射器。
    */
   private final MyOAuth2AuthorizationServerPropertiesMapper propertiesMapper;

   public ClientStoreConfig (MyOAuth2AuthorizationServerProperties properties) {
      this.propertiesMapper = new MyOAuth2AuthorizationServerPropertiesMapper(properties);
   }

   /**
    * 自定义注册'客户端'的保持方式。 可以自己实现
    * @return 注册客户端仓库实例。
    */
   @Bean
   public RegisteredClientRepository registeredClientRepository() {
      return new InMemoryRegisteredClientRepository(this.propertiesMapper.asRegisteredClients());
   }

}
